<template>
  <svg :class="['svg-icon', className]" :style="computedStyles" aria-hidden="true">
    <use :xlink:href="symbolId" />
  </svg>
</template>

<script setup>
import { computed } from 'vue'

const props = defineProps({
  name: {
    type: String,
    required: true
  },
  size: {
    type: [Number, String],
    default: 24
  },
  color: {
    type: String,
    default: 'currentColor'
  },
  className: {
    type: String,
    default: ''
  },
  rotate: {
    type: Number,
    default: 0
  }
})

const symbolId = computed(() => `#icon-${props.name}`)

const computedStyles = computed(() => ({
  '--icon-size': typeof props.size === 'number' ? `${props.size}px` : props.size,
  '--icon-color': props.color,
  '--icon-rotate': `${props.rotate}deg`
}))
</script>

<style scoped>
.svg-icon {
  display: inline-block;
  width: var(--icon-size, 24px);
  height: var(--icon-size, 24px);
  color: var(--icon-color, currentColor);
  fill: currentColor;
  vertical-align: middle;
  transform: rotate(var(--icon-rotate, 0deg));
  transition: all 0.3s ease;
}
</style>
